<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <meta http-equiv="Cache-control" content="no-cache">
	<meta http-equiv="Cache" content="no-cache">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/bootstrap-treeview.css" rel="stylesheet">
	<!-- 搜索样式CSS-Start -->
	<link href="/common/css/searchStyle.css" rel="stylesheet">
	<!-- 搜索样式CSS-End -->
	<!-- 下拉 -->
	<link href="/css/plugins/chosen/chosen.css" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-6">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="signupForm">
                           <div class="form-group">
								<label class="col-sm-3 control-label">参数配置名称：</label>
								<div class="col-sm-8">
								<input name="id" type="hidden">
									<input id="name" name="name" class="form-control" type="text"
										aria-required="true" aria-invalid="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">项目名称：</label>
								<div class="col-sm-5">
									<input type="text" id="projectName" name="projectName" readonly="readonly" class="form-control"
										onclick="$('#treeview').show()"> <input type="hidden"
										id="projectId" name="projectId">
									<div id="treeview" style="display: none;"></div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">服务器上传间隔(10的倍数)：</label>
								<div class="col-sm-8">
									<input id="iUpInterval" name="iupInterval" class="form-control"
										type="number" aria-required="true" aria-invalid="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">硬件上传间隔：</label>
								<div class="col-sm-8">
									<input id="hUpInterval" name="hupInterval" class="form-control"
										type="number" aria-required="true" aria-invalid="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">软件上传间隔：</label>
								<div class="col-sm-8">
									<input id="sUpInterval" name="supInterval" class="form-control"
										type="number" aria-required="true" aria-invalid="true">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">应用上传间隔：</label>
								<div class="col-sm-8">
									<input id="aUpInterval" name="aupInterval" class="form-control"
										type="number" aria-required="true" aria-invalid="true">
								</div>
							</div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-8">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="/js/plugins/validate/messages_zh.min.js"></script>
    <script src="/js/plugins/layer-pc/layer.js"></script>
    <script src="/common/form-validator.js"></script>
    <script src="/common/petecat.js"></script>
    <script src="/common/bootstrap-treeview.js"></script>
    <script src="/js/jquery.cookie.js"></script>
    <!-- HTML之间的传值 -->
	<script src="/js/jquery.params.js"></script>
    <!-- 组件通用 -->
    <script src="/common/frame.js"></script>
    <!-- 下拉 -->
	<script src="/js/plugins/chosen/chosen.jquery.js"></script>
	<script type="text/javascript">
		$(function(){
			$.ajax({
				type : "get",
				url : BASE_URL + '/base/project/queryProjectSelect',
				headers: {
			        Accept: "application/json; charset=utf-8",
			        Authorization: 'Bearer '+getSessionData('userToken')
				},
				success : function(data, status) {
					if(data.code == SUCCESS_CODE){
						var options = {
							bootstrap2 : true,
							showTags : false,
							levels : 1,
							data : data.data,
							onNodeSelected : function(event, data) {
								$("#projectName").val(data.text);
								$("#projectId").val(data.id);
								$("#treeview").hide();
							}
						};
					}else{
						layer.alert(data.message,{icon:2});
					}
					$('#treeview').treeview(options);
					var id = $("#projectId").val();
					$.each($("#treeview").treeview('getUnselected'),function(index,item){
						if(item.id == id){
							$("#treeview").treeview("selectNode",[item.nodeId,{silent:true}]);
							return;
						}
					});
				}
			});
			
			var e = "<i class='fa fa-times-circle'></i> ";
		    $("#signupForm").validate({
		    	rules : {
					name : {
						required : !0,
						minlength : 2
					},
					projectId:{
						required : !0
					},
					hupInterval:{
						required : !0
					},
					supInterval:{
						required : !0
					},
					aupInterval:{
						required : !0
					}
					
				},
				messages : {
					name : {
						required : e + "请输入公司名称",
						minlength : e + "公司名称必须两个字符以上"
					},
					hupInterval : {
						required : e + "请输入硬件上传间隔"
					},
					supInterval : {
						required : e + "请输入软件上传间隔"
					},
					aupInterval : {
						required : e + "请输入应用上传间隔"
					}
				},
		        submitHandler:function(form){
		            var data = serializeForm(form);
		        	var formData = JSON.stringify(data);
		        	var req = {};
		        	req['reqJSON'] = {
	        			type : 'put',
	        			url : BASE_URL+'/base/param/modifyParamById',
	        			data : formData
		        	};
		        	req['useToken'] = true;
		        	req['successFn'] = function(respData){
		        		layer.msg(respData.message, {icon: 6},function(){
        					if(respData.code == SUCCESS_CODE){
    						 	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
   	                        	parent.layer.close(index);  
        					}
        				}); 
		        	};
		        	ajaxRequest(req);
		        }
		    })
		});
		//间隔数字必须是10的倍数
		$("#hUpInterval,#sUpInterval,#aUpInterval,#iUpInterval").blur(function() {
			var $now = $(this);
			var value = $now.val();
			if (value == null || value == '') {
				value = 30;
			}
			var num = parseInt(value);
			//求余数
			var yu = num % 10;
			//不=0 说明不是10的倍数
			if(yu != 0){
				num -= yu;
				$now.val(num);
				layer.msg("系统已经为您转换为10的倍数！",{icon:6});
			}
		});
	</script>
</body>
</html>